import { configureStore, combineReducers } from "@reduxjs/toolkit";
import {persistStore, persistReducer} from 'redux-persist';
import storageSession from 'redux-persist/lib/storage/session';
import userReducer from './userSlice'

const storageConfig = {
    key: 'root', // 必须有的
    storage:storageSession, // 缓存机制
}

const reducer = combineReducers({
    user:userReducer
})
const myPersistReducer = persistReducer(storageConfig, reducer);

const store = configureStore({
    reducer:myPersistReducer,
    middleware: (getDefaultMiddleware) =>
        getDefaultMiddleware({
        serializableCheck: false,
    }), 
});
 
export const persistor = persistStore(store)
export default store;
// const store = configureStore({
//     reducer:{
//         user:userReducer
//     }
// })

// export default store